/*
 * @Author: your name
 * @Date: 2022-03-25 17:10:51
 * @LastEditTime: 2022-03-25 17:37:22
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \mallAdmin\src\app\main\recharge\compontents\follow-up\follow-up.service.ts
 */
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class FollowUpService {

  serviceUrls: any = {
    dictUrl: '/dict/detail', // 字典查询
    uploadFileUrl: '/common/upload/file', // 上传
 
    rechargeFollowerListUrl: '/jc/order/follow', // 图纸、充值专区跟进List
    rechargeFollowerSaveUrl: '/jc/order/follow' // 图纸、充值专区跟进提交
  };

  constructor(public httpClient: HttpClient) { }

  /**
   * 订单记录提交
   * @param params 
   * @returns 
   */
  saveFollowerItem(params: any) {
    return this.httpClient.post(this.serviceUrls.rechargeFollowerListUrl, params).toPromise();
  }

  /**
   * 订单记录查询
   * @param params
   * @returns 
   */
  queryFollowerListData(params: any) {
    let url: string = '';
    return this.httpClient.get(this.serviceUrls.rechargeFollowerSaveUrl, { params }).toPromise();
  }

  /**
   * 文件上传
   * @param fileToUpload 
   * @returns 
   */
  uploadFileData(fileToUpload: File, fileName?: any) {
    const formData: FormData = new FormData();
    formData.append('file', fileToUpload);
    formData.append('name', "order");
    if (fileName) {
      formData.append('fileName', fileName);
    }
    return this.httpClient.post(this.serviceUrls.uploadFileUrl, formData).toPromise();
  }
}



